/**
 * 约拍接口
 */
import request from '../lib/js/request'
import { BASE_URL } from './config'

/**
 * 发布约拍信息
 */
export function sendPublishDate(data) {
  return request({
    url: `${BASE_URL}/publishDatePat`,
    method: 'post',
    data: data
  })
}

/**
 * 获取主页约拍信息
 */
export function getIndexDatePatInfo(page, size) {
  page = page === undefined ? 1 : page
  size = size === undefined ? 5 : size
  return request({
    url: `${BASE_URL}/publishDatePat?page=${page}&size=${size}`,
    method: 'get'
  })
}

/**
 * 发送约拍请求
 * @param {} datePatId
 * @param {*} reason
 */
export function sendDatePatApply(datePatId, reason) {
  return request({
    url: `${BASE_URL}/publishDatePat/apply?datePatId=${datePatId}&datePatReason=${reason}`,
    method: 'post'
  })
}

/**
 * 获取用户收到的约拍请求
 */
export function getReceiveDatePatApply() {
  return request({
    url: `${BASE_URL}/publishDatePat/apply/receive`
  })
}

/**
 * 接受约拍请求
 */
export function acceptDatePatApply(applyId) {
  return request({
    url: `${BASE_URL}/publishDatePat/apply/accept?applyId=${applyId}`
  })
}

/**
 * 拒绝约拍请求
 */
export function refuseDatePatApply(applyId) {
  return request({
    url: `${BASE_URL}/publishDatePat/apply/refuse?applyId=${applyId}`
  })
}

/**
 * 获取用户发送的约拍请求
 */
export function getSendDatePatApply() {
  return request({
    url: `${BASE_URL}/publishDatePat/apply/send`
  })
}
